package com.vcc.boss.core.queue.transaction.model;


import jakarta.annotation.Resource;
import lombok.Data;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

@Data
public class RiskQueueDto implements Delayed {

    private String channelTransactionId;

    private Long time;

    @Override
    public long getDelay(@NotNull TimeUnit unit) {
        return unit.convert(time - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
    }

    @Override
    public int compareTo(@NotNull Delayed o) {
        return Long.compare(getDelay(TimeUnit.MILLISECONDS), o.getDelay(TimeUnit.MILLISECONDS));
    }

    public RiskQueueDto(String channelTransactionId, Long time) {
        this.channelTransactionId = channelTransactionId;
        this.time = time;
    }
}
